package com.bicon.botu.mall.base.rpc.service;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.bicon.botu.core.base.common.Constants;
import com.bicon.botu.core.base.common.controller.BaseController;
import com.bicon.botu.core.base.common.entity.BaseResult;
import com.bicon.botu.mall.base.common.ValidationUtil;
import com.bicon.botu.mall.base.entity.MallConfig;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

/**
 * 订单相关配置
 *
 * @author liushujie
 * @date 2018/5/8 0008 下午 16:05
 */
@Service
public class SystemConfigRpcService extends BaseController {

    /**
     * 根据字典code获取配置的属性值
     * @param dictionaryCode 配置的字典值
     * @return
     */
    @RequestMapping(value = "/order-config-value", method = RequestMethod.GET)
    public BaseResult getOderConfigValue(@RequestParam String dictionaryCode) {
        //检查code是否存在，若存在返回提示
        MallConfig mallConfig = new MallConfig().selectOne(new EntityWrapper<MallConfig>().eq("dictionary_code", dictionaryCode)
                .eq("logic_delete", Constants.DEL_LOGIC_NORMAL));
        if (ValidationUtil.isEmpty(mallConfig)) {
            return new BaseResult(Constants.RESPONSE_CODE_602, Constants.RESPONSE_MESSAGE_602);
        }
        return sendResult(Constants.RESPONSE_CODE_200, Constants.RESPONSE_MESSAGE_200, mallConfig);
    }

}
